﻿using HTB.DevFx;
using Maple.Weixin.MP.Helpers;

namespace Maple.Weixin.MP.Entities.Messages
{
    public class ResponseImage : ResponseMedia, IResponseService
    {
        private string mediaId;

        internal ResponseImage() {
            
        }

        public ResponseImage(string mediaId) {
            this.mediaId = mediaId;
        }

        public static ResponseImage CreateByFile(string fileName, out string result) {
            var responseImage = new ResponseImage();
            var mediaId = responseImage.UploadMedia(fileName, out result);
            if (string.IsNullOrEmpty(mediaId))
                return null;
            responseImage.mediaId = mediaId;
            return responseImage;
        }

        #region Implementation of IResponseService

        public ResponseMessageBase Handle(RequestMessageBase requestMessage) {
            var responseMessage = requestMessage.CreateImageResponse(mediaId);
            return responseMessage;
        }

        #endregion

        #region Overrides of ResponseMedia

        protected override UploadMediaType MediaType {
            get { return UploadMediaType.Image; }
        }

        #endregion
    }
}
